import axios from "~/axios";
import { queryParams } from "~/composables/util";

export function getOrder(page, query = {}) {
  let r = queryParams(query);
  return axios.get(`/order?page=${page}${r}`);
}

export function getPrint(page) {
  return axios.get("/print");
}

export function getExport(query = {}) {
  let q = [];
  for (const key in query) {
    if (query[key]) {
      q.push(`${key}=${encodeURIComponent(query[key])}`);
    }
  }
  let r = q.join("&");
  r = r ? "?" + r : "";

  return axios.get(`/export${r}`);
}

export function getinvoice(id) {
  return axios.get(`/order/${id}`);
}

//确认收货
export function updateOrder(id, data) {
  return axios.put(`/order/${id}`, data);
}
